<?php
namespace Home\Model;
use Think\Model;
class CommonModel extends Model {

    protected $_tableModel;
    protected $pk = 'id';

    public function __construct() {
        parent::__construct();
        $temp              = explode('_', $this->trueTableName);
        
        $tablename = '';
        if(count($temp) <= 2){
            $tablename = array_pop($temp);
        } else {
            foreach ($temp as $k => $v ){
                if($k != 0){
                    $tablename .= $v.'_';
                }
            }
            $tablename = trim($tablename,'_');
        }
        $this->_tableModel = M($tablename);
    }
    public function addData() {
        if ($this->_tableModel->create()) {
            $result = $this->_tableModel->add();
            return $result ? $result : 0;
        }
        return FALSE;
    }
}